package game.serverpackets;

import game.GameEngine;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;

public class ExHeroList extends ServerBasePacket
{
	private GameEngine _clientThread;
	private int _heroListSize;
	private Heroes[] myHeroes;
	public String _charName;
	public int _classId=0;
	public String _clanName;
	public int _clanCrest=0;
	public String _allyName;
	public int _allyCrest;
	public int _heroCount;

	public ExHeroList(GameEngine clientThread, byte data[])
	{
		_clientThread = clientThread;
		_buf = ByteBuffer.wrap(data);
		_buf.order(ByteOrder.LITTLE_ENDIAN);

//		readH();				//read message lenght
		readC();				// (1) message type
		readH();				// (2) message type
		_heroListSize = readD();

		myHeroes = new Heroes[_heroListSize];

		for(int i=0;i<_heroListSize;i++)
		{
			_charName = readS();
			_classId = readD();
			_clanName = readS();
			_clanCrest = readD();
			_allyName = readS();
			_allyCrest = readD();
			_heroCount = readD();
			myHeroes[i] = new Heroes(_charName,_classId,_clanName,_allyName,_heroCount);
		}
	}


	public void runImpl()
	{
		_clientThread.getVisualInterface().requestHeroesListDialog(myHeroes,_heroListSize);
	}

}
